/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bsc.war.form;

import bsc.ejb.metadata.Lang;
import bsc.war.delegate.DelegateBSC;
import bsc.war.factory.Factory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

/**
 *
 * @author luisZavaleta
 */
public class NewLang  extends AbstractController  {

     @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
         HttpServletResponse response) throws Exception {
        DelegateBSC delegate = (DelegateBSC) Factory.getBean("DelegateBSC");

        ModelAndView mav = new ModelAndView("addLang");
        try {

            Lang lang = (Lang) Factory.getBean("Lang");
            lang.setLenguage(Lang.Lenguage.valueOf(request.getParameter("lang")));
            delegate.createLang(lang);
            Lang.Lenguage[] leng = Lang.Lenguage.values();
            mav.addObject("langs", leng);

        } catch (Exception e) {
        }

        return mav;
    }

}
